import { ApiProperty, ApiPropertyOptional } from '@nestjs/swagger';
import { Type } from 'class-transformer';
import { IsNotEmpty, IsNumber, IsOptional, IsString } from 'class-validator';

// 查询职位列表
export class FindPositionDto {
  @ApiProperty({ default: 1, description: '当前页' })
  @Type(() => Number)
  @IsNumber()
  page: number = 1;

  @ApiProperty({ default: 10, description: '查询条数' })
  @Type(() => Number)
  @IsNumber()
  size: number = 10;

  @ApiPropertyOptional({ description: '父级分类' })
  @IsOptional()
  @Type(() => Number)
  @IsNumber()
  pid?: number;

  @ApiPropertyOptional({ description: '名称' })
  @IsOptional()
  @IsString()
  name?: string;

  @ApiPropertyOptional({ description: '启用状态' })
  @IsOptional()
  @Type(() => Number)
  @IsNumber()
  enableStatus?: number;

  @ApiPropertyOptional({ description: '热门职位' })
  @IsOptional()
  @Type(() => Number)
  @IsNumber()
  hot?: number;
}

// 根据职位名称搜索列表
export class SearchPositionDto {
  @ApiProperty({ description: '职位名称' })
  @IsNotEmpty()
  @IsString()
  name: string;
}

// 新增职位
export class CreatePositionDto {
  @ApiProperty({ description: '父级分类' })
  @IsNotEmpty()
  @IsNumber()
  pid: number;

  @ApiProperty({ description: '职位名称' })
  @IsNotEmpty()
  @IsString()
  name: string;

  @ApiProperty({ description: '启用状态' })
  @IsNotEmpty()
  @IsNumber()
  enableStatus: number;

  @ApiProperty({ description: '热门' })
  @IsNotEmpty()
  @IsNumber()
  hot: number;
}

// 更新职位
export class UpdatePositionDto extends CreatePositionDto {
  @ApiProperty({ description: 'ID' })
  @IsNotEmpty()
  @IsNumber()
  id: number;
}
